#!/bin/bash

#桥接网卡
#获取网卡
NW=`ip route | grep default | awk '{print $5}'`
#获取网关
GW=`ip route | grep default | awk '{print $3}'`
#获取IP
IPADDR=`cat /etc/sysconfig/network-scripts/ifcfg-$NW | grep IPADDR | awk -F '=' '{print $2}'`
echo 'BRIDGE=br0'>>/etc/sysconfig/network-scripts/ifcfg-$NW
cat > /etc/sysconfig/network-scripts/ifcfg-br0 << EOF
DEVICE=br0
TYPE=Bridge 
ONBOOT=yes 
BOOTPROTO=static
IPADDR=$IPADDR
PREFIX=24
GATEWAY=$GW
DNS1=223.5.5.5
DNS2=114.114.114.114
EOF
systemctl restart network

